package com.wc.AlgoOJ._数学.寻找完全平方数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/23 4:45
 * @description http://43.138.190.70:8888/p/MA0007
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = (int) 1e7 + 5000;
    static boolean[] st = new boolean[N];
    static int[] primes = new int[N / 10];
    static int cnt;


    public static void main(String[] args) {
        ola(N - 1);
        int T = sc.nextInt();
        while (T-- > 0) {
            long n = sc.nextLong();
            long ans = 1;
            for (int i = 0; primes[i] <= n / primes[i]; i++) {
                if (n % primes[i] == 0) {
                    int s = 0;
                    while (n % primes[i] == 0) {
                        s++;
                        n /= primes[i];
                    }
                    if ((s & 1) == 1) ans *= primes[i];
                }
            }
            if (n > 1) ans *= n;
            out.println(ans);
        }
        out.flush();
    }

    static void ola(int n) {
        st[0] = st[1] = true;
        for (int i = 2; i <= n; i++) {
            if (!st[i]) primes[cnt++] = i;
            for (int j = 0; primes[j] <= n / i; j++) {
                st[primes[j] * i] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
